package com.example.quartz.job;

import org.quartz.JobDetail;
import org.quartz.spi.TriggerFiredBundle;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.config.AutowireCapableBeanFactory;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.quartz.CronTriggerFactoryBean;
import org.springframework.scheduling.quartz.JobDetailFactoryBean;




@Configuration
public class QuartzSchedulerConfig {



    	@Bean(name = "systemTrigger")
        public CronTriggerFactoryBean job2Trigger(@Qualifier("systemJob") JobDetail jobDetail) {
            CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
            cronTriggerFactoryBean.setJobDetail(jobDetail);
            cronTriggerFactoryBean.setCronExpression("0 */1 * * * ?");
            return cronTriggerFactoryBean;
        }

        @Bean(name = "systemJob")
        public JobDetailFactoryBean job2Detail() {
            JobDetailFactoryBean jobDetailFactoryBean = new JobDetailFactoryBean();
            jobDetailFactoryBean.setJobClass(SystemJob.class);
            jobDetailFactoryBean.setDurability(true);
            return jobDetailFactoryBean;
        }



}
